package com.cloudsigns.factorymanager2.produce.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.IProductOrderWorkPartScheduleEditView;
import com.cloudsigns.factorymanager2.produce.model.IProductOrderWorkPartScheduleEditModel;
import com.cloudsigns.factorymanager2.produce.model.ProductOrderWorkPartScheduleEditModel;

public class ProductOrderWorkPartScheduleEditPresenter {
    private IProductOrderWorkPartScheduleEditView view;
    private IProductOrderWorkPartScheduleEditModel model;
    private Handler handler = new Handler();

    public ProductOrderWorkPartScheduleEditPresenter(IProductOrderWorkPartScheduleEditView view) {
        this.view = view;
        this.model = new ProductOrderWorkPartScheduleEditModel();
    }

    public void productOrderWorkPartScheduleEdit() {
        model.getProductOrderWorkPartScheduleEdit(view.getOrderId(), view.getProductId(), view.getWorkPartId(), view.getList(), new ProductOrderWorkPartScheduleEditModel.OnProductOrderWorkPartScheduleEditListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
